<?php
use yii\widgets\Breadcrumbs;
use yii\widgets\LinkPager;
use app\modules\core\models\Field;
use app\modules\core\widgets\SlideNav;

$this->title = '字段列表';
?>

<div class="container-fluid">
	<div class="row">
        <?= SlideNav::widget() ?>

		<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 col-lg-10 col-lg-offset-2 main">
            <?= Breadcrumbs::widget([
                'homeLink' => ['label' => 'HOME', 'url' => '/core'],
                'links' => [
                    '字段',
                ]
            ]) ?>
			
			
			<div class="row">
				<div class="col-md-12 col-lg-12">
					<div class="alert alert-warning">
						<button type="button" class="close" data-dismiss="alert">×</button>
						<strong>警告!</strong> 请注意你的个人隐私安全.
					</div>
					<div class="">
						<a type="button" class="btn btn-primary pull-right" data-dismiss="alert" href="/core/field/create">新建</a>
                        
						<a type="button" class="btn btn-primary pull-right" data-dismiss="alert" href="/core/field/install">安装</a>
					</div>
					<table class="table">
						<thead>
							<tr>
								<th>
									名字
								</th>
								<th>
									描述
								</th>
								<th>
									命名空间
								</th>
								<th>
									验证器
								</th>
								<th>
									数据类型
								</th>
								<th>
									数据源类型
								</th>
								<th>
									视图
								</th>
								<th>
                                    是否必需
								</th>
							</tr>
						</thead>
						<tbody>
                            <?php foreach ($fields as $field) { ?>
							    <tr>
							    	<td>
							    		<?php echo $field['name']; ?>
							    	</td>
							    	<td>
							    		<?php echo $field['desc']; ?>
							    	</td>
							    	<td>
							    		<?php echo $field['classNs']; ?>
							    	</td>
							    	<td>
							    		<?php echo isset($field['validates']) ? implode(',', $field['validates']) : '' ?>
							    	</td>
							    	<td>
							    		<?php echo Field::$fieldTypes[$field['type']]; ?>
							    	</td>
							    	<td>
							    		<?php echo Field::$stypes[$field['sourceType']]; ?>
							    	</td>
							    	<td>
							    		<?php echo Field::$viewList[$field['view']]; ?>
							    	</td>
							    	<td>
							    		<?php echo $field['required'] ? '必需' : '选填'; ?>
							    	</td>
							    </tr>
                            <?php } ?>
						</tbody>
					</table>
                    <?php echo LinkPager::widget(['pagination' => $pagination, 'hideOnSinglePage' => false]) ?>
				</div>
			</div>
		</div>
	</div>
</div>
